package cn.melon.view.admin.course.ctr;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

import cn.melon.mod.sc.ScInfo;
import cn.melon.mod.sc.ScRequest;
import cn.melon.view.admin.course.AddCourseDlg;
import cn.melon.view.admin.course.IUpdateCourseTable;

public class AddCourseDlgCtr implements ActionListener {
    
    private AddCourseDlg addCourseDig = null;
    private ScRequest request;
    
    
    public AddCourseDlgCtr(AddCourseDlg dlg, IUpdateCourseTable updateCourseTable){
        this.addCourseDig = dlg; 
        request = new ScRequest(updateCourseTable);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        switch (e.getActionCommand()) {
        case "保存":
            ScInfo info = addCourseDig.getScInfo();
            if (info.getClassNumber().equals("")) {
                JOptionPane.showMessageDialog(null, "请填写课程号码");
                return ;
            }

            request.addInfo(info);
            addCourseDig.setVisible(false);
            break;
        case "取消":
            addCourseDig.setVisible(false);
            break;
        default:
            break;
        }

    }

}
